package com.hspedu.homework;

import java.util.HashSet;
import java.util.TreeSet;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/2/10
 * @time 19:02
 */
public class TestHashSet {
    public static void main(String[] args) {
        HashSet hashSet = new HashSet();
        for (int i = 0; i < 12; i++) {
            hashSet.add(i);
        }
        hashSet.add(new Test(15));
        hashSet.add(new Test(15));

        TreeSet treeSet = new TreeSet();
        treeSet.add(new Test(1));
        treeSet.add(new Test(2));
    }
}

class Test{
    private int i;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Test test = (Test) o;
        return i == test.i;
    }

    @Override
    public int hashCode() {
        return 65536;
    }

    public Test(int i) {
        this.i = i;
    }
}
